package cn.iocoder.yudao.module.member.controller.app.banner;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.member.dal.dataobject.banner.AppBannerDO;
import cn.iocoder.yudao.module.member.service.banner.AppBannerService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "小程序 - 轮播图")
@RestController
@RequestMapping("/banner")
@Validated
public class AppBannerController {

    @Resource
    private AppBannerService bannerService;

    @GetMapping("/list")
    @Operation(summary = "获得轮播图列表")
    public CommonResult<List<String>> getBannerList() {
        List<AppBannerDO> bannerList = bannerService.getBannerList();
        List<String> urls = bannerList.stream().map(AppBannerDO::getImgUrl).collect(Collectors.toList());
        return success(urls);
    }

}
